/**
 * @description 能源消费数据
 */

import request from '@/utils/request';

const baseURL = '/energy/consumption';

/**
 * 获取平台能源大类列表
 * @returns Promise<any>
 */
export const getEnergyTypes = () => request.get(`${baseURL}/type/list`);

/**
 * 数据总览-能源消费情况分析
 * @param {{timeType: string, time: string, enterpriseId?:string|number}} params 时间类型和时间
 * @returns Promise<any>
 */
export const getEnergyConsumption = params =>
  request({
    url: `${baseURL}/overview/analysis`,
    method: 'get',
    params
  });

/**
 * 数据总览-能源消费总量趋势
 * @param {{timeType: string, time: string, enterpriseId?:string|number}} params 时间类型和时间
 * @returns Promise<any>
 */
export const getEnergyConsumptionTrend = params =>
  request({
    url: `${baseURL}/overview/total`,
    method: 'get',
    params
  });

/**
 * 数据总览-能源消费结构及占比
 * @param {{timeType: string, time: string,enterpriseId?:string|number}} params 时间类型和时间
 * @returns Promise<any>
 */
export const getEnergyConsumptionStructure = params =>
  request({
    url: `${baseURL}/overview/proportion`,
    method: 'get',
    params
  });

/**
 * 数据总览-数据分析-数据图表
 * @param {string} energyType 能源种类 如：```electric``` ```water```
 * @param {string} timeType
 * @param {string} time
 * @param {string} enterpriseId 可选
 * @returns Promise<any>
 */
export const getEnergyConsumptionChart = (energyType, timeType, time, enterpriseId) =>
  request({
    url: `${baseURL}/overview/analysis/chart/${energyType}`,
    method: 'get',
    params: {
      time,
      timeType,
      enterpriseId,
    }
  });

/**
 * 数据总览-数据分析-企业能源消费top5
 * @param {string} energyType 能源种类 如：```electric``` ```water```
 * @param {string} timeType 时间类型
 * @param {string} time 时间
 * @param {number} top top榜前n名 如：```5```
 * @returns Promise<any>
 */
export const getEnergyConsumptionTop = (energyType, timeType, time, top = 5) =>
  request({
    url: `${baseURL}/overview/analysis/top/${top}/${energyType}`,
    method: 'get',
    params: {
      time,
      timeType
    }
  });

/**
 * 区域数据-区域能源消费统计
 * @param {{timeType: string, time: string}} params
 * @returns
 */
export const getEnergyConsumptionTable = params =>
  request({
    url: `${baseURL}/area/statistics`,
    method: 'get',
    params
  });

/**
 * 区域数据-区域能源消费table表
 * @param {{timeType: string, time: string, energyTypeList: string[]}} params
 * @returns
 */
export const getAreaEnergyConsumptionTable = params =>
  request({
    url: `${baseURL}/area/table`,
    method: 'get',
    params
  });

/**
 * 区域数据-区域下公司-能源消费table表
 * @param {string} areaCode
 * @param {{timeType: string, time: string, energyTypeList: string[]}} params
 * @returns
 */
export const getCompanyEnergyConsumptionTable = (areaCode, params) =>
  request({
    url: `${baseURL}/area/company/table/${areaCode}`,
    method: 'get',
    params
  });

/**
 * 行业数据-行业能源消费统计
 * @param {{timeType: string, time: string}} params 时间类型和时间
 * @returns
 */
export const getIndustryEnergyConsumption = params =>
  request({
    url: `${baseURL}/industry/statistics`,
    method: 'get',
    params
  });

/**
 * 行业数据-行业能源消费table表
 * @param {{timeType: string, time: string, energyTypeList: string[]}} params
 * @returns
 */
export const getIndustryEnergyConsumptionTable = params =>
  request({
    url: `${baseURL}/industry/table`,
    method: 'get',
    params
  });

/**
 * 行业数据-行业下公司-能源消费table表
 * @param {string} industryCode
 * @param {{timeType: string, time: string, energyTypeList: string[]}} params
 * @returns
 */
export const getIndustryCompanyEnergyConsumptionTable = (
  industryCode,
  params
) =>
  request({
    url: `${baseURL}/industry/company/table/${industryCode}`,
    method: 'get',
    params
  });

/** 查询平台区域列表 */
export const getAreaList = () =>
  request({
    url: `${baseURL}/area/map`
  });


/** 区域分析-查询区域下企业能源消费数据 */
export const getAreaCompanyEnergyConsumption = (areaCode, params) =>
  request({
    url: `${baseURL}/area/company/info/table/${areaCode}`,
    method: 'get',
    params
  });

/** 行业分析-查询行业下企业能源消费数据 */
export const getIndustryCompanyEnergyConsumption = (industryCode, params) =>
  request({
    url: `${baseURL}/industry/company/info/table/${industryCode}`,
    method: 'get',
    params
  });
